<%@ page import="com.goal98.team.Constants" %>
<head>
  <meta name="layout" content="main"/>
  <title><g:message code="team.list" default="Player List"/></title>
</head>

<body>

  <div class="nav">
  %{--<span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span>--}%
    <g:ifAnyGranted role="${Constants.ROLE_TEAM_ADMIN}">
      <span class="menuButton"><g:link class="create" action="create"><g:message code="player.create" default="New Player"/></g:link></span>
    </g:ifAnyGranted>
  </div>

  <div class="body">
    <h1><g:message code="team.list" default="Player List"/></h1>
    <g:if test="${flash.message}">
      <div class="message">${flash.message}</div>
    </g:if>
    <div class="list">
      <table>
        <thead>
          <tr>
            %{--<g:sortableColumn property="id" title="Id" />--}%
            <g:sortableColumn property="position" title="${message(code:'player.position', 'default':'Position')}"/>
            <g:sortableColumn property="username" title="${message(code:'register.id', 'default':'Login Name')}"/>
            <g:sortableColumn property="userRealName" title="${message(code:'register.fullName', 'default':'Full Name')}"/>
            <g:sortableColumn property="team" title="${message(code:'player.team', 'default':'Team')}"/>
            <g:sortableColumn property="teamAdmin" title="${message(code:'player.teamAdmin', 'default':'Team Admin')}"/>
            <g:sortableColumn property="enabled" title="${message(code:'register.enabled', 'default':'Enabled')}"/>
            <g:ifAnyGranted role="${Constants.ROLE_TEAM_ADMIN + ',' + Constants.ROLE_ADMIN}">
              <g:sortableColumn property="account.balance" title="${message(code:'account.balance', 'default':'Balance')}"/>
            </g:ifAnyGranted>
            %{--<g:sortableColumn property="description" title="Description"/>--}%
            <th>&nbsp;</th>
          </tr>
        </thead>
        <tbody>
          <g:each in="${personList}" status="i" var="person">
            <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
              %{--<td>${person.id}</td>--}%
              <td>${person.position?.encodeAsHTML()}</td>
              <td>${person.username?.encodeAsHTML()}</td>
              <td>${person.userRealName?.encodeAsHTML()}</td>
              <td>${person.team?.encodeAsHTML()}</td>
              <td>${person.teamAdmin?.encodeAsHTML()}</td>
              <td>${person.enabled?.encodeAsHTML()}</td>
              <g:ifAnyGranted role="${Constants.ROLE_TEAM_ADMIN + ',' + Constants.ROLE_ADMIN}">
                <td>${person.account?.balance}</td>
              </g:ifAnyGranted>
            %{--<td>${person.description?.encodeAsHTML()}</td>--}%
              <td class="actionButtons">
                <span class="actionButton">
                  <g:link action="show" id="${person.id}"><g:message code="button.show" default="Show"/></g:link>
                </span>
                <g:ifAnyGranted role="${Constants.ROLE_TEAM_ADMIN}">
                  <span class="actionButton">
                    <g:link action="edit" id="${person.id}"><g:message code="button.edit" default="Edit"/></g:link>
                  </span>
                  <span class="actionButton">
                    <g:link action="account" id="${person.id}"><g:message code="button.credit" default="Credit"/></g:link>
                  </span>
                </g:ifAnyGranted>
              </td>
            </tr>
          </g:each>
        </tbody>
      </table>
    </div>
    %{--<g:ifAnyGranted role="${Constants.ROLE_ADMIN}">
      <div class="paginateButtons">
        <g:paginate total="${Person.count()}"/>
      </div>
    </g:ifAnyGranted>--}%

  </div>
</body>
